package com.koron.operation.dispatch.mapper;

import com.koron.common.core.business.configsettings.bean.ConfigDetailQuery;
import com.koron.operation.dispatch.bean.DispatchDeptBean;
import com.koron.operation.dispatch.bean.EquipmentBaseBean;
import com.koron.operation.dispatch.bean.EquipmentBean;
import com.koron.operation.dispatch.bean.UnitRelationDo;
import com.koron.operation.dispatch.bean.dto.EquipmentDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

public interface EquipmentDeMapper {
    int deleteByPrimaryKey(String id);

    int insert(EquipmentBean record);

    int insertSelective(EquipmentBean record);

    EquipmentBean selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(EquipmentBean record);

    int updateByPrimaryKey(EquipmentBean record);

    int updateBatch(List<EquipmentBean> list);

    int updateBatchSelective(List<EquipmentBean> list);

    int batchInsert(@Param("list") List<EquipmentBean> list);

    //列表
    List<EquipmentBean> queryList(EquipmentDto queryBean);

    // 根据设备类型找出排序号不为空的记录
    List<EquipmentBean> queryByEquipmentTypeAndSortNotNull(@Param("equipmentType")String equipmentType, @Param("deptManage") String deptManage);

    // 根据设备类型找出排序号为空的记录
    List<EquipmentBean> queryByEquipmentTypeAndSortIsNull(@Param("equipmentType")String equipmentType, @Param("deptManage") String deptManage);

    // 更新排序序号
    int updateSortByEquipmentId(@Param("updatedSort")Integer updatedSort,@Param("equipmentId")String equipmentId);

    List<EquipmentBaseBean> queryAll();

    //根据设备id 查设备
    EquipmentBean queryFirstByEquipmentId(@Param("equipmentId") String equipmentId);

    @Select(" select dept_manage_name,dept_manage from w_dispatch_equipment where derail = 0 group by dept_manage_name, dept_manage_name ")
    List<DispatchDeptBean> queryAllDispatchDept();

    //根据配置id 和 租户appid 查出 机组对应关系
    List<UnitRelationDo> getUnitrelationlist(ConfigDetailQuery configdetailquery);

    // 设备交换排序查询
    List<EquipmentBean> queryByEquipmentIdIn(@Param("equipmentIdCollection")Collection<String> equipmentIdCollection);

    // 单位交换排序查询
    List<EquipmentBean> queryByDeptManageIn(@Param("deptManageCollection")Collection<String> deptManageCollection);

    // 根据设备类型找出排序号不为空的记录
    List<EquipmentBean> queryDeptManageAndDeptManageNameAndDeptSortByDeptSortIsNotNull();

    // 根据设备类型找出排序号为空的记录
    List<EquipmentBean> queryDeptManageAndDeptManageNameAndDeptSortByDeptSortIsNull();

    // 根据单位更新dept_sort
    int updateDeptSortByDeptManage(@Param("updatedDeptSort")Integer updatedDeptSort,@Param("deptManage")String deptManage);

    // 根据台账id更新启用标记
    int updateDerailByEquipmentIdIn(@Param("updatedDerail")Integer updatedDerail,@Param("equipmentIdCollection")Collection<String> equipmentIdCollection);

    EquipmentBean queryByDeptManageAndDeptSortNotNull(@Param("deptManage")String deptManage);



}
